package com.labichaoka.chaoka.net;

import android.util.Log;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okio.BufferedSink;

/**
 * Created by ruan on 2018/6/8.
 */

public class RequestInterceptor implements Interceptor{

    @Override
    public Response intercept(Interceptor.Chain chain) throws IOException {
//        Request request = chain.request()
//                .newBuilder()
//                .addHeader("Content-Type", "application/json;charset=utf-8")
//                .addHeader("Connection", "keep-alive")
//                .addHeader("Accept", "*/*")
//                .addHeader("Access-Control-Allow-Origin", "*")
//                .addHeader("Access-Control-Allow-Headers", "X-Requested-With")
//                .addHeader("Vary", "Accept-Encoding")
//                .build();
//
//        Log.v("zcb", "request:" + request.toString());
//        Log.v("zcb", "request headers:" + request.headers().toString());
//
//        return chain.proceed(request);

        Request.Builder builder = chain.request()
                .newBuilder();
        builder.post(new RequestBody() {

            @Override
            public MediaType contentType()
            {
                return MediaType.parse("application/json");
            }


            @Override
            public void writeTo(BufferedSink sink) throws IOException
            {


            }
        });

        Request request = builder.build();

        return chain.proceed(request);
    }
}
